home *** CD-ROM | disk | FTP | other *** search
- /*
- * FILE: anringpi.c
- * AUTHOR: R. Gonzalez
- * CREATED: November 8, 1990
- *
- * Sample animated pict application. Includes main() function.
- *
- * ASSOCIATED FILES:
- * anringpi.h,class.c,class.h,screen.c,screen.h,,coord.c,coord.h,
- * frame.c,frame.h,color.h,error.c,error.h,trans.c,trans.h,oops.h,
- * camera.c,camera.h,project.c,project.h,segment.c,segment.h,
- * line.c,line.h,cube.c,cube.h,anring.c,anring.h,backdrop.c,
- * backdrop.h,pict.c,pict.h,animate.h,animate.c,atring.c,atring.h,
- * several ANSI and system-specific headers (used in screen.c
- * and class.c).
- *
- * PROJECT CONTENTS (Think C):
- * above-listed source (.c) files, MacTraps, ANSI or ANSI-881,
- * oops library.
- *
- * COMPILATION (Think C):
- * 68881 code generation if ANSI-881 is used.
- */
-
- # include "anringpi.h"
- # include "anring.h"
- # define NUM_ITERATIONS 100
-
- /******************************************************************
- * initialize
- ******************************************************************/
- boolean An_Ring_Pict::init(void)
- {
- Translation *transl;
-
- Generic_Pict::init();
-
- projector1 = new(Projector);
- projector1->init();
- projector1->set_background_color(RED);
- projector1->set_cropping_frame(0.,-.05,1.,.5);
- projector1->set_projection_frame(0.,0.,1.8,.9);
-
- projector2 = new(Corner_Projector);
- projector2->init();
-
- projector1->set_screen(screen);
- projector2->set_screen(screen);
-
- camera1 = new(Camera);
- camera1->init();
- camera1->set_position(0.,3.,0.,0.,.29,0.);
- camera2 = new(Camera);
- camera2->init();
- camera2->set_position(0.,100.,10.,0.,PI/2.,0.);
- camera2->set_focal_length(20.);
-
- transl = new(Translation);
- transl->init();
- transl->set(0.,0.,10.);
-
- segment = new(Animated_Ring);
- segment->init();
- segment->move(transl);
-
- transl->destroy();
- delete(transl);
-
- return TRUE;
- }
-
- /******************************************************************
- * run
- ******************************************************************/
- void An_Ring_Pict::run(void)
- {
- int i;
- Transformation *identity;
-
- identity = new(Transformation);
- identity->init();
-
- for (i=0 ; i<NUM_ITERATIONS && !screen->mouse_button_is_down() ; i++)
- {
- projector1->clear();
- segment->set_color(YELLOW);
- segment->draw(camera1,projector1,identity);
- projector2->clear();
- segment->set_color(BLUE);
- segment->draw(camera2,projector2,identity);
- segment->animate();
- }
-
- screen->wait();
-
- identity->destroy();
- delete(identity);
- }
-
- /******************************************************************
- * destroy
- ******************************************************************/
- boolean An_Ring_Pict::destroy(void)
- {
- projector1->destroy();
- delete(projector1);
- projector2->destroy();
- delete(projector2);
-
- camera1->destroy();
- delete(camera1);
- camera2->destroy();
- delete(camera2);
-
- segment->destroy();
- delete(segment);
-
- return Generic_Pict::destroy();
- }
-
- /******************************************************************
- * main function
- ******************************************************************/
- main()
- {
- Generic_Pict *pict;
-
- pict = new(An_Ring_Pict);
- pict->init();
- pict->run();
- pict->destroy();
- delete(pict);
- }
-
-
-